package com.frank.leftJoinQuery.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

/**
 * @author 小石潭记
 * @date 2020/12/12 18:32
 * @Description: ${todo} B表
 */
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_student")
public class Student {
    @Id
    private Long id;
    private String name;
    private String address;
    private String accountNumber;
    private String grade;

    // 同时在B表里添加A表记录的id  默认A表名 + "_id"
    // 这里感觉就是 Teacher 小写teacher  + "_id"
    // private Teacher teacher; 应该是根据这里的teacher来的 @OneToMany(mappedBy="teacher")
    // @JsonIgnoreProperties("teacher")  这里的teacher名字需要保持一致
    @Column(name = "teacher_id", insertable = false, updatable = false)
    private Long teacherId;

    @ManyToOne
    @JsonIgnoreProperties("studentList") //该注解可防止json转换进入死循环
    private Teacher teacher;
}
